package com.commonly.string.tokenizer;

import java.util.StringTokenizer;

public class StringTokenizerReturnDelimiterExample {
	public static void main(String[] args) {

		/*
		 * By default, StringTokenizer object does not return the delimiters
		 * along with the string tokens. To return the delimiter along with the
		 * string tokens, use StringTokenizer(String str, String delim, boolean
		 * returnDelims) construcor
		 */

		// Create StringTokenizer object
		StringTokenizer st = new StringTokenizer(
				"Java|StringTokenizer|Example 1", "|", true);

		System.out.println("count:"+st.countTokens());
		// iterate through tokens
		while (st.hasMoreTokens())
			System.out.println(st.nextToken("|"));

	}
}
